﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WMS.BLL;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string loginID = StringUtil.QueryStringToGuid("LoginID");
        //string loginID = Guid.NewGuid().ToString();
        string loginID = "38E4D67F-CCF6-4FC9-98F1-8690F836AAC1";
        WMS.Model.OrderOnline_User model_OrderOnline_User = new WMS.BLL.OrderOnline_User().GetByLoginID(loginID);
        if (model_OrderOnline_User != null)
        {
            CookieManager.ID = model_OrderOnline_User.LoginID;
            CookieManager.CII = model_OrderOnline_User.CII;
            CookieManager.CIIDES = Server.UrlEncode(model_OrderOnline_User.CIIDES);
            CookieManager.PCII = model_OrderOnline_User.PCII;
            CookieManager.WHSWHS = model_OrderOnline_User.WHSWHS;
            CookieManager.WHSLOC = model_OrderOnline_User.WHSLOC;
            CookieManager.UserName = model_OrderOnline_User.UserName;
            CookieManager.RealName = Server.UrlEncode(model_OrderOnline_User.RealName);
            CookieManager.RoleID = model_OrderOnline_User.RoleID;

            WMS.Model.OrderOnline_Role model_OrderOnline_Role = new WMS.BLL.OrderOnline_Role().GetByID(model_OrderOnline_User.RoleID);
            if (model_OrderOnline_Role != null)
            {
                //CookieManager.RolePermission = String.Format("'{0}'", model_OrderOnline_Role.Rights.Replace(",", "','"));
                string strRolePermission = String.Format("'{0}'", model_OrderOnline_Role.Rights.Replace("#", "").Replace("_", "','"));
                //若最后一个为“，”，则替换为“”
                if (strRolePermission[strRolePermission.Length - 1] == ',')
                {
                    strRolePermission = strRolePermission.Substring(0, strRolePermission.Length - 2);
                }
                CookieManager.RolePermission = strRolePermission.Replace(",", "','");
            }
        }

        Response.Redirect("Main.aspx");
    }
}